package cn.hg.solon.youcan.framework.config;

import org.noear.redisx.RedisClient;
import org.noear.solon.annotation.Bean;
import org.noear.solon.annotation.Configuration;
import org.noear.solon.annotation.Inject;
import org.noear.solon.data.cache.CacheService;
import org.noear.solon.data.cache.CacheServiceSupplier;
import org.noear.solon.data.cache.CacheTagsService;

import cn.hg.solon.youcan.framework.cache.CacheTagsServiceProvider;
import cn.hg.solon.youcan.framework.cache.YoucanCacheService;

/**
 * @author 胡高
 */
@Configuration
public class CacheConfig {
    @Bean
    public CacheTagsService cacheTags(@Inject CacheService cacheService) {
        return (CacheTagsService) cacheService;
    }

    @Bean
    public RedisClient redisClient(@Inject("${youcan.cache}") RedisClient redisClient) {
        return redisClient;
    }

    @Bean
    public CacheService youcanCahce(@Inject("${youcan.cache}") CacheServiceSupplier supplier) {
        return new CacheTagsServiceProvider(supplier.get());
    }

    @Bean
    public YoucanCacheService youcanTags(@Inject CacheTagsService cacheService) {
        return (YoucanCacheService) cacheService;
    }
}
